// 测试自定义面值功能
console.log('测试自定义面值功能');

// 模拟页面数据
const pageData = {
    showCustomAmountDialog: false,
    customAmount: '',
    customAmountError: '',
    selectedPrice: 0,
    topicPrices: [
        { id: 1, price: 50, tip: '50元' },
        { id: 2, price: 100, tip: '100元' },
        { id: 3, price: 200, tip: '200元' }
    ]
};

// 测试方法
function testCustomAmountInput() {
    console.log('测试点击自定义面值按钮');
    pageData.showCustomAmountDialog = true;
    pageData.customAmount = '';
    pageData.customAmountError = '';
    console.log('对话框状态:', pageData.showCustomAmountDialog);
}

function testCustomAmountChange(value) {
    console.log('测试输入变化:', value);
    pageData.customAmount = value;
    pageData.customAmountError = '';
    console.log('当前输入值:', pageData.customAmount);
}

function testConfirmCustomAmount() {
    console.log('测试确认自定义面值');
    const amount = parseFloat(pageData.customAmount);
    
    // 验证输入
    if (!pageData.customAmount || pageData.customAmount.trim() === '') {
        pageData.customAmountError = '请输入面值金额';
        console.log('错误:', pageData.customAmountError);
        return;
    }
    
    if (isNaN(amount) || amount <= 0) {
        pageData.customAmountError = '请输入有效的金额';
        console.log('错误:', pageData.customAmountError);
        return;
    }
    
    if (amount > 10000) {
        pageData.customAmountError = '面值不能超过10000元';
        console.log('错误:', pageData.customAmountError);
        return;
    }

    // 设置选中的价格
    pageData.selectedPrice = amount;
    pageData.showCustomAmountDialog = false;
    pageData.customAmount = '';
    pageData.customAmountError = '';
    
    console.log('设置成功，选中价格:', pageData.selectedPrice);
    console.log('对话框已关闭');
}

function testCancelCustomAmount() {
    console.log('测试取消自定义面值');
    pageData.showCustomAmountDialog = false;
    pageData.customAmount = '';
    pageData.customAmountError = '';
    console.log('对话框已关闭');
}

// 运行测试
console.log('=== 开始测试 ===');
console.log('初始状态:', pageData);

testCustomAmountInput();
testCustomAmountChange('150.50');
testConfirmCustomAmount();

console.log('最终状态:', pageData);
console.log('=== 测试完成 ===');
